<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>在字符串中检索表达式</title>
</head>

<body>
    <h1>JavaScript 正则表达式</h1>
    <p>在字符串中搜索“w3School” 并显示匹配的位置：</p>
    <p id="demo"></p>
    <script>
        var str = "Visit W3School!";
        var n = str.search(/w3School/i);
        document.getElementById("demo").innerHTML = n;
    </script>
</body>

</html>